﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.ComponentModel;

namespace WarOfDev.Core.Common
{
    public static class EnumExtension
    {
        public static string GetEnumDescription(this Enum e)
        {
            FieldInfo fieldInfo = e.GetType().GetField(e.ToString());

            object[] objs = fieldInfo.GetCustomAttributes(true);

            if (objs.Length <= 0)
            {
                return string.Empty;
            }

            DescriptionAttribute desAttr = objs[0] as DescriptionAttribute;

            return desAttr.Description;
        }
    }
}
